# 了解
# po模式
# po是page object的缩写，是一种自动化测试的设计模式
# 将一个页面定位元素的功能，设计为一个页面类
# 以后我们可以通过页面类定位元素

# 假如一个页面中只有两个元素
# 一个元素是账号输入框，另一个元素是密码输入框
# 我们把这个页面设计成页面类
# 这样做的好处是，当页面元素变化时，只需要修改类中的元素定位代码，不需要在别的地方修改


import time
from pywinauto.keyboard import send_keys
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

class lagin:
    def __init__(self):
        self.driver = webdriver.Edge()
        self.driver.get("file:///D:/pagetest/注册A.html")
    def find_user_name(self):
        ele = self.driver.find_element(By.CSS_SELECTOR,'#userA')
        return ele
    def find_password(self):
        ele1 = self.driver.find_element(By.CSS_SELECTOR,'#passwordA')
        return ele1
    def find_d(self):
        ele2 = self.driver.find_element(By.CSS_SELECTOR,'#telA')
        return ele2
    def find_y(self):
        ele3 = self.driver.find_element(By.CSS_SELECTOR,'body > div.zc > fieldset > form > p:nth-child(4) > input')
        return ele3
    def quit(self):
        self.driver.quit()

login = lagin()
time.sleep(3)
# 输入王大锤
login.find_user_name().send_keys('王大锤')
time.sleep(3)
# 在密码框中输入123456
login.find_password().send_keys('123456')
time.sleep(3)
# 在电话号码中输入13523130791
login.find_d().send_keys('13523130791')
time.sleep(3)
# 清空输入框
login.find_user_name().clear()
time.sleep(3)
# 输入王心凌
login.find_user_name().send_keys('王心凌')
time.sleep(500)
login.quit()


# # 创建驱动对象
# driver = webdriver.Edge()
# # 打开网页
# driver.get("file:///D:/pagetest/注册A.html")
# # 最大化窗口函数  驱动对象名.maximize_window()
# driver.maximize_window()
# time.sleep(3)
#
# # # 账号输入框输入 王大锤
# # driver.find_element(By.CSS_SELECTOR,'#userA').send_keys('王大锤')
# # time.sleep(3)
# # # 清空
# # driver.find_element(By.CSS_SELECTOR,'#userA').clear()
# # time.sleep(3)
# # # 账号输入框输入 王心凌
# # driver.find_element(By.CSS_SELECTOR,'#userA').send_keys('王心凌')
#
# def find_user_name():
#     ele = driver.find_element(By.CSS_SELECTOR,'#userA')
#     return ele
# # 在输入框内输入 王大锤
# find_user_name().send_keys('王大锤')
# # 过三秒清空
# time.sleep(3)
# find_user_name().clear()
# # 账号框输入王心凌
# find_user_name.send_keys('王心凌')
#

# 关闭网页
# time.sleep(200)
# driver.quit()




